package com.chatplus.application.controller.api;

import com.chatplus.application.common.logging.SouthernQuietLogger;
import com.chatplus.application.common.logging.SouthernQuietLoggerFactory;
import com.chatplus.application.common.page.PageParam;
import com.chatplus.application.domain.request.PlusPageRequest;
import com.chatplus.application.domain.response.InviteCodeListResponse;
import com.chatplus.application.domain.response.PlusPageResponse;
import com.chatplus.application.web.basecontroller.BaseController;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 订单API
 */
@Validated
@RestController
@RequestMapping("/api/order")
@Tag(name = "订单API", description = "订单API")
public class OrderApiController extends BaseController {
    static final SouthernQuietLogger LOGGER = SouthernQuietLoggerFactory.getLogger(OrderApiController.class);


    @PostMapping("/list")
    @Operation(summary = "邀请列表")
    public PlusPageResponse<InviteCodeListResponse> list(@RequestBody PlusPageRequest plusPageRequest) {
        PageParam pageParam = new PageParam(plusPageRequest.getPage(), plusPageRequest.getPageSize());
//        Page<InviteLogEntity> inviteLogsPage = inviteLogsService.page(pageParam.toPage(), Wrappers.<InviteLogEntity>lambdaQuery()
//                .eq(InviteLogEntity::getInviterId, getUserId())
//                .orderByDesc(InviteLogEntity::getCreatedAt));
//        List<InviteLogEntity> inviteLogsList = inviteLogsPage.getRecords();
//        if (CollUtil.isEmpty(inviteLogsList)) {
//            return new PlusPageResponse<>(plusPageRequest.getPage(), plusPageRequest.getPageSize(), 0, 0, Lists.newArrayList());
//        }
//        List<InviteCodeListResponse> inviteCodeListResponseList = inviteLogsList.stream().map(item -> {
//            InviteCodeListResponse inviteCodeListResponse = BeanUtil.copyProperties(item, InviteCodeListResponse.class);
//            inviteCodeListResponse.setCreatedAt(item.getCreatedAt().getEpochSecond() / 1000);
//            return inviteCodeListResponse;
//        }).collect(Collectors.toList());

//        return new PlusPageResponse<>(plusPageRequest.getPage(), plusPageRequest.getPageSize()
//                , inviteLogsPage.getPages(), inviteLogsPage.getTotal(), inviteCodeListResponseList);
        return null;
    }
}
